 <?php  
    echo $this->session->flash(); 
    if(!empty($payeeData)){
        $this->Paginator->options(array(
           'update' => '#divUpdate',
           'evalScripts' => true, 
        ));

    } 
?>
<div class="file" id="List">
       <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#686550">
        <tr class="heading"  bgcolor="#708089">
            <td width="6%" valign="top" align="left"><?php  echo __('S.NO');?></td>
            <td valign="top" width="30%" align="left"><?php echo $this->Paginator->sort('eng_name', __('ENG_NAME',true)); ?></td>
            <td valign="top" width="30%" align="left"><?php echo $this->Paginator->sort('chi_name', __('CHI_NAME',true)); ?></td>
            <td valign="top" width="20%" align ="left"><?php echo $this->Paginator->sort('payee_id_proof_no', __('PAYEE_ID_PROOF_NO',true)); ?></td>
            <td valign="top" width="20%" align ="left"><?php echo $this->Paginator->sort('joining_date', __('JOINING_DATE',true)); ?></td>
            <td valign="top" width="10%" align ="left"><?php echo __('COUNT_CONTRACT'); ?></td>
            <td valign="top" width="10%" align ="left"><?php echo __('COUNT_ID'); ?></td>
            <td valign="top" width="20%" align ="left"><?php echo $this->Paginator->sort('created', __('CREATED',true)); ?></td>
            <td valign="top" width="10%" align="left"><?php  echo __('ACTION');?></td>
        </tr>
	<?php
        if(isset($payeeData) && count($payeeData)>0){
            $i=0;
            foreach($payeeData as $arrayDetail){
                $contractCount = $idCount = 0;
                if(count($arrayDetail['File'])){
                    foreach ($arrayDetail['File'] as $files){
                        if($files['type'] == 'contact'){
                            $contractCount++;
                        }
                        if($files['type'] == 'id'){
                            $idCount++;
                        }
                    }
                }
            ?>
            <tr class="heading2" bgcolor="#ffffff">
		    <td>&nbsp;<?php echo $i+1?></td>
		    
		     <td>&nbsp;<?php echo $arrayDetail['Payee']['eng_name'];?></td>
                     <td>&nbsp;<?php echo $arrayDetail['Payee']['chi_name'];?></td>
                     <td>&nbsp;<?php echo $arrayDetail['Payee']['payee_id_proof_no'];?></td>
                     <td>&nbsp;<?php echo ($arrayDetail['Payee']['joining_date'] != '0000-00-00')? date('M j, Y', strtotime($arrayDetail['Payee']['joining_date'])) : '';?></td>
                     <td>&nbsp;<?php echo $contractCount;?></td>
                     <td>&nbsp;<?php echo $idCount;?></td>
		     <td>&nbsp;<?php echo date('M j, Y', strtotime($arrayDetail['Payee']['created']));?></td>
		     <td><?php
		     $showSeparator = 0;
			if(!$roleId || $showPayeeEditURL){//No checks for superadmin
                            echo $this->html->link(
                                $this->Html->image('icons/16/edit_user.png'), 
                                array(
                                    'controller' => 'payees',
                                    'action' => 'edit', $arrayDetail['Payee']['id']
                                ), array(
                                    'alt' => __('EDIT', true),
                                    'title' => __('EDIT', true),
                                    'escape'=>false
                                )
                            );
			    $showSeparator = 1;
                        }

                        if(!$roleId || $showPayeeDeleteURL){//No checks for superadmin
			    if($showSeparator){
				 echo ' | ';
			      }
                            echo $this->Js->link(
                                $this->Html->image('icons/16/cross.png', array('title'=>'Delete Payee')),
                                array(
                                    'controller' => 'payees', 
                                    'action' => 'delete_payee/'.$arrayDetail['Payee']['id']
                                ),
                                array(
                                    'update' => '#divUpdate',
                                    'escape'=>false,
                                    'before' => $this->Js->get('#processingDiv')->effect('fadeIn'),
                                    'success' => $this->Js->get('#processingDiv')->effect('fadeOut'),
                                    'confirm' => 'Are you sure you wish to delete this Payee? You can\'t revert it back'
                                )
                            );
                        }
			?>
		     </td>
              </tr>  
          <?php
          $i++;
          }
        }
        ?>
	<tr><td colspan="9" bgcolor="#ffffff" align="center"><div class="pagination">            
	      <?php		     
	      if(!empty($payeeData)){
		     echo $this->Element('pagination');
	      } else{
		     echo __("NO_RECORD_MESSAGE");
	      }
              ?>              
          </div></td></tr>
	
	<tr bgcolor="#ffffff">
	    <td colspan="9" valign="top">
	       <table width="25%">
		  <tr>
		     <td width="10%">
			<b><?php echo __('LEGENDS')?> :- </b> 
		     </td>
		     <td width="10%">
			<?php echo $this->html->image('/img/icons/16/edit_icon.png');?>

			<?php echo __('EDIT')?>
		     </td>
		     
		      
		  </tr>
		</table>
	    </td>
	 </tr>
       </table>
</div>
<?php echo $this->Js->writeBuffer();?>